package com.hhz.mp;

import com.hhz.mp.mapper.UserMapper2;
import com.hhz.mp.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * Sql 注入器
 *
 * @Author Rem
 * @Date 2020-03-01
 */

@RunWith(SpringRunner.class)
@SpringBootTest
public class MyApplicationTest6 {

    @Autowired
    UserMapper2 userMapper2;

    /**
     * 自定义方法
     *
     * slelect 不再是每个字段名称 而是自己定义的 select *
     * SELECT * FROM tb_user
     */
    @Test
    public void testFindAll() {
        List<User> users = userMapper2.findAll();
        users.forEach(System.err::println);
    }

    /**
     * baseMapper的方法
     * SELECT id, user_name, name, age, email AS mail, version, deleted, sex FROM tb_user
     */
    @Test
    public void testSelectOne() {

        List<User> users = userMapper2.selectList(null);
        users.forEach(System.err::println);
    }

}
